<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>忘记密码</title>
    
    <jsp:include page="../common/common.jsp"></jsp:include>
	<link rel="stylesheet" href="<%=request.getContextPath() %>/resources/js/mybootstrap/css/bootstrap.css" />
	<link href="<%=request.getContextPath() %>/resources/css/system/index/common.css" rel="stylesheet"></link>
	<link href="<%=request.getContextPath() %>/resources/css/system/index/login.css"  rel="stylesheet"></link>
 
    
  </head>
  
  <body class="client-body">
  		<jsp:include page="forgetPassHead.jsp"></jsp:include>
  		
  		<div class="client-content fp-content">
	  		<form class="fp-form" action="" id="reset_form">
	  			<div class="fp-formTitle">密码找回</div>
	  			
	  			<div class="fp-formContent">
	  				<div class="fp-formHead">2、设置新密码</div>
	  				
					<div class="list-tr">
						<input type="hidden" value="${phone}" name="phone">
						<input type="password" name="password" id="password" placeholder="新密码" />
					</div>
					<div class="list-tr">
						<input type="password" name="repwd" id="repwd" placeholder="确认新密码" />
					</div>
					
					<div class="foot-box2 fp-formBtn clearfix">
						<a class="left a-white btn2" href="">取消</a>
						<a class="right a-white btn2" href="" id="ok">确定</a>
					</div>
					
					<div class="error-resgister">
						<span id="errorContent"></span><!-- 错误提示 -->
					</div>
				</div>
	  		</form> 
  		</div>

<script src="<%=request.getContextPath() %>/resources/js/jquery/1.12.4/jquery.min.js"></script>
<script src="<%=request.getContextPath() %>/resources/js/system/index/jquery.md5.js"></script>
<script type="text/javascript">
var re2=/(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,16}$/;

$(document).ready(function(){
	infoSure();  
});

function infoSure(){

	$("#ok").click(function(){
	
		var phone=$("#phone").val();
		var password=$("#password").val();
		var repwd=$("#repwd").val();
		
		if(password=="" || repwd==""){
			$(".error-resgister").css("display","block");
			$("#errorContent").text("您所填信息不完整！");
		}else if(!re2.test(password)){
			$(".error-resgister").css("display","block");
			$("#errorContent").text("密码必须为6~16位字符至少包含数字.字母.符号中的2种！");
		}else if(password != repwd){
			$(".error-resgister").css("display","block");
			$("#errorContent").text("您两次输入的密码不一致！");
		}else{
			$("#errorContent").text("");
			submit_data();
		}
	});
}

function submit_data(){
	//md5加密传输
    $("#password").val($.md5($("#repwd").val()));
    
    $.ajax({
		type: "post",
        url:CONTEXT_PATH+'before/forgetpass/resetPass',
		data:$('#reset_form').serialize(), 
		async: false,
		success: function(data) {
			alert(data.message);
			if(data.flag==true){
				window.location.href='<%=request.getContextPath() %>/before/login';
			} 
		}
	});
} 
</script>
    
  </body>
</html>
